package model.invocatedMethods;

import model.observer.SensorObserver;
import model.subject.Sensor;

/**
 * Implémentation de l'interface Runnable utilisée pour la notification des changements de valeur du capteur auprès des observeurs.
 */
public class RunnableUpdateImpl implements Runnable {

	private SensorObserver observer;
	private Sensor subject;
	
	private long latency;	// Latence
	
	public RunnableUpdateImpl(SensorObserver observer, Sensor subject, long latency) { 
		this.observer = observer;
		this.subject = subject;
		
		this.latency = latency;
	}
	
	@Override
	public void run() {
		try {
			Thread.sleep(latency);	// Simulation de la latence
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		observer.update(subject);	
	}

}
